import 'package:app/pages/login_modules/register_module/register_controller.dart';
import 'package:app/pages/login_modules/register_module/register_set_password_module/register_setpassword_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_verification_code/flutter_verification_code.dart';
import 'package:get/get.dart';

import '../../../utils/hexcolor.dart';

class RegisterGetCodeView extends GetView{

  var phoneStr;

  RegisterGetCodeView({this.phoneStr});

  RegisterController controller = Get.put(RegisterController());

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        // leading: new IconButton(
        //   icon: Image.asset(A.assets_arrback_icon),
        //   onPressed: () => {
        //     Navigator.of(context).pop('刷新')
        //   },
        // ),
      ),
      body: GetBuilder<RegisterController>(builder: (_){
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              margin: EdgeInsets.only(top: 10, left: 20),
              child: Text('获取验证码'.tr, style: TextStyle(fontSize: 24,
                  color: HexColor('#333333'),
                  fontWeight: FontWeight.w500),),
            ),
            Container(
              margin: EdgeInsets.only(top: 5, left: 20),
              child: Text('验证码已经发送给到您的手机'.tr,
                style: TextStyle(fontSize: 12, color: HexColor('#999999')),),
            ),
            Container(
              margin: EdgeInsets.only(top: 5, left: 20),
              child: Text('+86 ${phoneStr}',
                style: TextStyle(fontSize: 12, color: HexColor('#999999')),),
            ),

            Container(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    margin: EdgeInsets.only(top: 50, left: 25),
                    child: Text('6位数验证码'.tr, style: TextStyle(
                        fontSize: 12, color: HexColor('#999999')),),
                  ),

                  Container(
                    margin: EdgeInsets.only(top: 50, left: 25, right: 25),
                    child: GestureDetector(
                      child: Text(''),
                      onTap: () {
                        // logic.requestDataSendCode(widget.phoneStr).then((value) {
                        //   if (value['errcode'] == 0) {
                        //     logic.countdownTime.value = 59;
                        //     BotToast.showText(text: value['message']);
                        //   }
                        // });
                      },
                    ),
                  )
                ],
              ),
            ),
            Container(
              // color: Colors.red,
              margin: EdgeInsets.only(left: 15, right: 15, top: 10),
              height: 55,
              width: Get.width,
              child: VerificationCode(
                digitsOnly: true,
                fullBorder: true,
                autofocus: true,
                length: 6,
                onCompleted: (String value) {
                  print('完成');
                  Get.to(RegisterSetPasswordView( phoneStr:phoneStr,codeStr:value));

                  // controller.pushToSetPassWord(value);
                },
                onEditing: (bool value) {

                },

              ),
              // VerificationBox(
              //   onSubmitted: (value) {
              //     print('${value}');
              //     Get.to(RegisterSetPasswordPage(widget.phoneStr, value));
              //   },
              //   focusBorderColor: Theme
              //       .of(context)
              //       .primaryColor,
              //   showCursor: true,
              //   textStyle: TextStyle(fontSize: 28, color: HexColor('#242A36')),
              //   borderColor: HexColor('#D2D6DC'),
              //   borderWidth: 1,
              // ),
            ),
          ],
        );
      }),
    );
  }

}